﻿#include "dxstdafx.h"
#include "CStrategyLogicWorld.h"
#include "CStrategyLogicMapMsgHandle.h"

void CStrategyLogicWorld::CreateStrategyLogicLoop()
{
	while (true)
	{
		WORD wSleepTime = 0;
		if (Singleton().GetSleepTime(&wSleepTime))
		{
			Singleton().DayChange();
		}
		std::this_thread::sleep_for(std::chrono::milliseconds(wSleepTime));
	}
}

bool CStrategyLogicWorld::HandleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (CStrategyLogicMapMsgHandle::Singleton().HandleMessages(hWnd, uMsg, wParam, lParam))
	{
		return true;
	}
	return false;
}

bool CStrategyLogicWorld::GetSleepTime(WORD* wSleepTime)
{
	switch (m_nTimePassLevel)
	{
	case TimePass_1:
		*wSleepTime = 3000;
		break;
	case TimePass_2:
		*wSleepTime = 2000;
		break;
	case TimePass_3:
		*wSleepTime = 1000;
		break;
	case TimePass_4:
		*wSleepTime = 500;
		break;
	case TimePass_5:
		*wSleepTime = 200;
		break;
	case TimePass_0:
	default:
		*wSleepTime = 100;
		return false;
		break;
	}
	return true;
}

void CStrategyLogicWorld::DayChange()
{
	++m_tWorldDate;
	printf("%d年%d月%d日\n", m_tWorldDate.GetYear(), m_tWorldDate.GetMonth(), m_tWorldDate.GetDay());
}
